<template>
    <view class="page" v-if="isLoad">
        <video :src="src" class="video" @play="star" @pause="end" controls></video>
    </view>
</template>

<script>
    import api from '@/api/api.js';
    export default {
        data() {
            return {
                src: '',
                id: '',
                sTime: '',
            }
        },
        onLoad(o) {
            this.id = this.getS('video').id
            this.src = this.getS('video').src
            this.isLoad = 1
        },
        methods: {
            star() {
                this.sTime = Date.now()
            },
            end() {
                let n = Date.now()
                let time = parseInt((n - this.sTime) / 1000)
                //上报时长 单位秒
                console.log(time);
                this.sTime = 0
            }
        }
    }
</script>

<style lang="scss">
    .video {
        width: 100vw;
        height: 100vh;
    }
</style>